home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / classify < prev    next >
Encoding:
Text File  |  1992-02-29  |  39.5 KB  |  1,209 lines

  1. Newsgroups: comp.sources.unix
  2. From: mjd@saul.cis.upenn.edu (Mark-Jason Dominus)
  3. Subject: v25i136: classify - compare groups of files and classify them
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: mjd@saul.cis.upenn.edu (Mark-Jason Dominus)
  8. Posting-Number: Volume 25, Issue 136
  9. Archive-Name: classify
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of shell archive."
  18. # Contents:  COPYING Makefile README classify.1 classify.c test0 test1
  19. #   test2 test3 test4
  20. # Wrapped by vixie@cognition.pa.dec.com on Sat Feb 29 20:19:14 1992
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'COPYING' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'COPYING'\"
  24. else
  25. echo shar: Extracting \"'COPYING'\" \(12488 characters\)
  26. sed "s/^X//" >'COPYING' <<'END_OF_FILE'
  27. X
  28. X            GNU GENERAL PUBLIC LICENSE
  29. X             Version 1, February 1989
  30. X
  31. X Copyright (C) 1989 Free Software Foundation, Inc.
  32. X                    675 Mass Ave, Cambridge, MA 02139, USA
  33. X Everyone is permitted to copy and distribute verbatim copies
  34. X of this license document, but changing it is not allowed.
  35. X
  36. X                Preamble
  37. X
  38. X  The license agreements of most software companies try to keep users
  39. at the mercy of those companies.  By contrast, our General Public
  40. License is intended to guarantee your freedom to share and change free
  41. software--to make sure the software is free for all its users.  The
  42. General Public License applies to the Free Software Foundation's
  43. software and to any other program whose authors commit to using it.
  44. You can use it for your programs, too.
  45. X
  46. X  When we speak of free software, we are referring to freedom, not
  47. price.  Specifically, the General Public License is designed to make
  48. sure that you have the freedom to give away or sell copies of free
  49. software, that you receive source code or can get it if you want it,
  50. that you can change the software or use pieces of it in new free
  51. programs; and that you know you can do these things.
  52. X
  53. X  To protect your rights, we need to make restrictions that forbid
  54. anyone to deny you these rights or to ask you to surrender the rights.
  55. These restrictions translate to certain responsibilities for you if you
  56. distribute copies of the software, or if you modify it.
  57. X
  58. X  For example, if you distribute copies of a such a program, whether
  59. gratis or for a fee, you must give the recipients all the rights that
  60. you have.  You must make sure that they, too, receive or can get the
  61. source code.  And you must tell them their rights.
  62. X
  63. X  We protect your rights with two steps: (1) copyright the software, and
  64. X(2) offer you this license which gives you legal permission to copy,
  65. distribute and/or modify the software.
  66. X
  67. X  Also, for each author's protection and ours, we want to make certain
  68. that everyone understands that there is no warranty for this free
  69. software.  If the software is modified by someone else and passed on, we
  70. want its recipients to know that what they have is not the original, so
  71. that any problems introduced by others will not reflect on the original
  72. authors' reputations.
  73. X
  74. X  The precise terms and conditions for copying, distribution and
  75. modification follow.
  76. X
  77. X            GNU GENERAL PUBLIC LICENSE
  78. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  79. X
  80. X  0. This License Agreement applies to any program or other work which
  81. contains a notice placed by the copyright holder saying it may be
  82. distributed under the terms of this General Public License.  The
  83. X"Program", below, refers to any such program or work, and a "work based
  84. on the Program" means either the Program or any work containing the
  85. Program or a portion of it, either verbatim or with modifications.  Each
  86. licensee is addressed as "you".
  87. X
  88. X  1. You may copy and distribute verbatim copies of the Program's source
  89. code as you receive it, in any medium, provided that you conspicuously and
  90. appropriately publish on each copy an appropriate copyright notice and
  91. disclaimer of warranty; keep intact all the notices that refer to this
  92. General Public License and to the absence of any warranty; and give any
  93. other recipients of the Program a copy of this General Public License
  94. along with the Program.  You may charge a fee for the physical act of
  95. transferring a copy.
  96. X
  97. X  2. You may modify your copy or copies of the Program or any portion of
  98. it, and copy and distribute such modifications under the terms of Paragraph
  99. X1 above, provided that you also do the following:
  100. X
  101. X    a) cause the modified files to carry prominent notices stating that
  102. X    you changed the files and the date of any change; and
  103. X
  104. X    b) cause the whole of any work that you distribute or publish, that
  105. X    in whole or in part contains the Program or any part thereof, either
  106. X    with or without modifications, to be licensed at no charge to all
  107. X    third parties under the terms of this General Public License (except
  108. X    that you may choose to grant warranty protection to some or all
  109. X    third parties, at your option).
  110. X
  111. X    c) If the modified program normally reads commands interactively when
  112. X    run, you must cause it, when started running for such interactive use
  113. X    in the simplest and most usual way, to print or display an
  114. X    announcement including an appropriate copyright notice and a notice
  115. X    that there is no warranty (or else, saying that you provide a
  116. X    warranty) and that users may redistribute the program under these
  117. X    conditions, and telling the user how to view a copy of this General
  118. X    Public License.
  119. X
  120. X    d) You may charge a fee for the physical act of transferring a
  121. X    copy, and you may at your option offer warranty protection in
  122. X    exchange for a fee.
  123. X
  124. Mere aggregation of another independent work with the Program (or its
  125. derivative) on a volume of a storage or distribution medium does not bring
  126. the other work under the scope of these terms.
  127. X
  128. X  3. You may copy and distribute the Program (or a portion or derivative of
  129. it, under Paragraph 2) in object code or executable form under the terms of
  130. Paragraphs 1 and 2 above provided that you also do one of the following:
  131. X
  132. X    a) accompany it with the complete corresponding machine-readable
  133. X    source code, which must be distributed under the terms of
  134. X    Paragraphs 1 and 2 above; or,
  135. X
  136. X    b) accompany it with a written offer, valid for at least three
  137. X    years, to give any third party free (except for a nominal charge
  138. X    for the cost of distribution) a complete machine-readable copy of the
  139. X    corresponding source code, to be distributed under the terms of
  140. X    Paragraphs 1 and 2 above; or,
  141. X
  142. X    c) accompany it with the information you received as to where the
  143. X    corresponding source code may be obtained.  (This alternative is
  144. X    allowed only for noncommercial distribution and only if you
  145. X    received the program in object code or executable form alone.)
  146. X
  147. Source code for a work means the preferred form of the work for making
  148. modifications to it.  For an executable file, complete source code means
  149. all the source code for all modules it contains; but, as a special
  150. exception, it need not include source code for modules which are standard
  151. libraries that accompany the operating system on which the executable
  152. file runs, or for standard header files or definitions files that
  153. accompany that operating system.
  154. X
  155. X  4. You may not copy, modify, sublicense, distribute or transfer the
  156. Program except as expressly provided under this General Public License.
  157. Any attempt otherwise to copy, modify, sublicense, distribute or transfer
  158. the Program is void, and will automatically terminate your rights to use
  159. the Program under this License.  However, parties who have received
  160. copies, or rights to use copies, from you under this General Public
  161. License will not have their licenses terminated so long as such parties
  162. remain in full compliance.
  163. X
  164. X  5. By copying, distributing or modifying the Program (or any work based
  165. on the Program) you indicate your acceptance of this license to do so,
  166. and all its terms and conditions.
  167. X
  168. X  6. Each time you redistribute the Program (or any work based on the
  169. Program), the recipient automatically receives a license from the original
  170. licensor to copy, distribute or modify the Program subject to these
  171. terms and conditions.  You may not impose any further restrictions on the
  172. recipients' exercise of the rights granted herein.
  173. X
  174. X  7. The Free Software Foundation may publish revised and/or new versions
  175. of the General Public License from time to time.  Such new versions will
  176. be similar in spirit to the present version, but may differ in detail to
  177. address new problems or concerns.
  178. X
  179. XEach version is given a distinguishing version number.  If the Program
  180. specifies a version number of the license which applies to it and "any
  181. later version", you have the option of following the terms and conditions
  182. either of that version or of any later version published by the Free
  183. Software Foundation.  If the Program does not specify a version number of
  184. the license, you may choose any version ever published by the Free Software
  185. XFoundation.
  186. X
  187. X  8. If you wish to incorporate parts of the Program into other free
  188. programs whose distribution conditions are different, write to the author
  189. to ask for permission.  For software which is copyrighted by the Free
  190. Software Foundation, write to the Free Software Foundation; we sometimes
  191. make exceptions for this.  Our decision will be guided by the two goals
  192. of preserving the free status of all derivatives of our free software and
  193. of promoting the sharing and reuse of software generally.
  194. X
  195. X                NO WARRANTY
  196. X
  197. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  198. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  199. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  200. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  201. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  202. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  203. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  204. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  205. REPAIR OR CORRECTION.
  206. X
  207. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  208. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  209. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  210. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  211. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  212. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  213. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  214. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  215. POSSIBILITY OF SUCH DAMAGES.
  216. X
  217. X             END OF TERMS AND CONDITIONS
  218. X
  219. X    Appendix: How to Apply These Terms to Your New Programs
  220. X
  221. X  If you develop a new program, and you want it to be of the greatest
  222. possible use to humanity, the best way to achieve this is to make it
  223. free software which everyone can redistribute and change under these
  224. terms.
  225. X
  226. X  To do so, attach the following notices to the program.  It is safest to
  227. attach them to the start of each source file to most effectively convey
  228. the exclusion of warranty; and each file should have at least the
  229. X"copyright" line and a pointer to where the full notice is found.
  230. X
  231. X    <one line to give the program's name and a brief idea of what it does.>
  232. X    Copyright (C) 19yy  <name of author>
  233. X
  234. X    This program is free software; you can redistribute it and/or modify
  235. X    it under the terms of the GNU General Public License as published by
  236. X    the Free Software Foundation; either version 1, or (at your option)
  237. X    any later version.
  238. X
  239. X    This program is distributed in the hope that it will be useful,
  240. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  241. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  242. X    GNU General Public License for more details.
  243. X
  244. X    You should have received a copy of the GNU General Public License
  245. X    along with this program; if not, write to the Free Software
  246. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  247. X
  248. Also add information on how to contact you by electronic and paper mail.
  249. X
  250. If the program is interactive, make it output a short notice like this
  251. when it starts in an interactive mode:
  252. X
  253. X    Gnomovision version 69, Copyright (C) 19xx name of author
  254. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  255. X    This is free software, and you are welcome to redistribute it
  256. X    under certain conditions; type `show c' for details.
  257. X
  258. The hypothetical commands `show w' and `show c' should show the
  259. appropriate parts of the General Public License.  Of course, the
  260. commands you use may be called something other than `show w' and `show
  261. c'; they could even be mouse-clicks or menu items--whatever suits your
  262. program.
  263. X
  264. You should also get your employer (if you work as a programmer) or your
  265. school, if any, to sign a "copyright disclaimer" for the program, if
  266. necessary.  Here a sample; alter the names:
  267. X
  268. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  269. X  program `Gnomovision' (a program to direct compilers to make passes
  270. X  at assemblers) written by James Hacker.
  271. X
  272. X  <signature of Ty Coon>, 1 April 1989
  273. X  Ty Coon, President of Vice
  274. X
  275. That's all there is to it!
  276. END_OF_FILE
  277. if test 12488 -ne `wc -c <'COPYING'`; then
  278.     echo shar: \"'COPYING'\" unpacked with wrong size!
  279. fi
  280. # end of 'COPYING'
  281. fi
  282. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  283.   echo shar: Will not clobber existing file \"'Makefile'\"
  284. else
  285. echo shar: Extracting \"'Makefile'\" \(162 characters\)
  286. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  287. X
  288. CFLAGS=    -O
  289. CC=    gcc
  290. all: classify
  291. X
  292. classify: classify.c
  293. X    $(CC) $(CFLAGS) classify.c -o classify
  294. X
  295. clean: 
  296. X    rm -f classify *.o a.out core *~
  297. X
  298. X.SCCS_GET:
  299. X    co -l $*
  300. X
  301. END_OF_FILE
  302. if test 162 -ne `wc -c <'Makefile'`; then
  303.     echo shar: \"'Makefile'\" unpacked with wrong size!
  304. fi
  305. # end of 'Makefile'
  306. fi
  307. if test -f 'README' -a "${1}" != "-c" ; then 
  308.   echo shar: Will not clobber existing file \"'README'\"
  309. else
  310. echo shar: Extracting \"'README'\" \(1514 characters\)
  311. sed "s/^X//" >'README' <<'END_OF_FILE'
  312. X    `classify' is a utility for comparing many files to each
  313. other all at once.  For example, if you manage a collection
  314. of diskless workstations, you can see which machines are
  315. using the same rc.local file by executing the command
  316. X
  317. X    classify /export/root/*/etc/rc.local
  318. X
  319. X(or something like it ) on the server machine.
  320. X
  321. X    If you want to edit the motd files on these
  322. workstations, you can use a script like this:
  323. X
  324. X    foreach i ( `classify -1 /export/root/*/etc/motd` )
  325. X        set ifamily=`classify -m $i /export/root/*/etc/motd`
  326. X        $EDITOR $i
  327. X        foreach j ($ifamily)
  328. X            cp $i $j
  329. X        end
  330. X    end
  331. X
  332. which groups the motd files into classes of identical files,
  333. invokes the editor on one motd from each class, and then
  334. propagates the changes to the other motds in each class.
  335. X
  336. X    The `test?' files are sample inputs so you can see what
  337. X`classify' is doing.  Some of the `test' files differ only
  338. in the case of some of their letters; some have extraneous
  339. whitespace of various types, some are really the same as
  340. each other ands some are genuinely different.
  341. X
  342. To-Do:
  343. X
  344. X    `classify' might have better performance if it did
  345. X`stat' on files it was comparing to see what their i-numbers
  346. were; if two files are on the same device and have the same
  347. i-number, then they are necessarily identical, and don't
  348. need to be compared character-by-character.  It might also
  349. be worthwhile to keep a cache of the first block or so of
  350. one file from each class, to save repeatedly opening and
  351. closing files.
  352. X
  353. Mark-Jason Dominus
  354. mjd@saul.cis.upenn.edu
  355. END_OF_FILE
  356. if test 1514 -ne `wc -c <'README'`; then
  357.     echo shar: \"'README'\" unpacked with wrong size!
  358. fi
  359. # end of 'README'
  360. fi
  361. if test -f 'classify.1' -a "${1}" != "-c" ; then 
  362.   echo shar: Will not clobber existing file \"'classify.1'\"
  363. else
  364. echo shar: Extracting \"'classify.1'\" \(3519 characters\)
  365. sed "s/^X//" >'classify.1' <<'END_OF_FILE'
  366. X.TH CLASSIFY 1 "25 Nov 1991"
  367. X.SH NAME 
  368. classify \- group files that are identical (modulo whitespace)
  369. X.SH SYNOPSIS
  370. X.B classify 
  371. X[
  372. X.B \-s
  373. X|
  374. X.B \-l
  375. X|
  376. X.B \-1
  377. X|
  378. X.B \-m
  379. X|
  380. X.B \-M
  381. X]
  382. X[
  383. X.B \-b
  384. X|
  385. X.B \-w
  386. X]
  387. X[
  388. X.B \-f
  389. X]
  390. X.if n .ti +5 
  391. X[
  392. X.B \-\|\-
  393. X|
  394. X.B \-
  395. X]
  396. X.I filename1 filename2
  397. X[
  398. X.IR filename3 .\|.\|.
  399. X]
  400. X.SH DESCRIPTION
  401. X.B Classify
  402. is a program designed to help manage a set of files such as the
  403. X/etc/rc.local or /etc/motd files for a collection of diskless
  404. workstations.  
  405. X.B Classify
  406. examines each of the files named in its arguments, groups
  407. them into 
  408. X.IR classes ,
  409. with files that are almost identical in
  410. the same class, and files that are not very much alike in
  411. different classes, and outputs a brief report.  For example:
  412. X.PP
  413. X.B sterno napalm
  414. X.br
  415. X.B moe larry curly
  416. X.br
  417. X.B holy_grail
  418. X.PP
  419. This output indicates that files 
  420. X.BR sterno " and " napalm 
  421. are identical in content, that 
  422. X.BR moe ", " larry ", and " curly
  423. are all three the same as each other but different from 
  424. X.BR sterno " and " napalm ", "
  425. and that 
  426. X.B holy_grail
  427. is different from all the others.
  428. X.PP
  429. The other function of
  430. X.B classify
  431. is to produce a list of files which are almost the same as a
  432. single other file.
  433. X.B Classify
  434. ignores files which it cannot open for whatever reason,
  435. continuing on its way. 
  436. X.PP
  437. X.SH OPTIONS
  438. X.br
  439. X.TP
  440. X.B \-l
  441. Select long output form.  This format is unnecessary, but is still around
  442. for convenience and hystorical reasons.  The `long' form of the example
  443. output above is:
  444. X.PP
  445. X.DS
  446. Class 1:
  447. X.br
  448. X    sterno
  449. X.br
  450. X    napalm
  451. X.PP
  452. Class 2:
  453. X.br
  454. X    moe
  455. X.br
  456. X    larry
  457. X.br
  458. X    curly
  459. X.PP
  460. Class 3:
  461. X.br
  462. X    holy_grail
  463. X.DE
  464. X.TP
  465. X.B \-s
  466. Select short output form:  Print the names of the files in
  467. each class together on a single line.  This is the default.  See the
  468. example above.
  469. X.TP
  470. X.B \-1
  471. Select very short output form:  Print on the standard
  472. output the name of only one file 
  473. from each class. 
  474. X.TP
  475. X.B \-M
  476. Produce on the standard output a list of all the 
  477. X.IR filename s
  478. which are identical in content to 
  479. X.IR filename1 .
  480. X.TP
  481. X.B \-m
  482. Like 
  483. X.BR \-M,
  484. but omit
  485. X.I filename1
  486. itself from the output.
  487. X.TP
  488. X.B \-b
  489. Ignore blanks and tabs when comparing the named files.
  490. X.TP
  491. X.B \-w
  492. Ignore blanks, tabs, and newline characters when comparing
  493. files.
  494. X.TP
  495. X.B \-f 
  496. XFold in lower case.  Treat upper- and lower- case letters
  497. equally when comparing files.
  498. X.TP
  499. X.B \-
  500. X.TP
  501. X.B  \-\|\-
  502. Treat the following arguments as filenames so that you can
  503. specify filenames starting with a `-' character.
  504. X.TP
  505. X.B \-h
  506. Print summary of correct usage.
  507. X.LP
  508. If more than one of
  509. X.BR \-l ", " \-s ", " \-1 ,
  510. X.BR \-M ", "
  511. or 
  512. X.B \-m
  513. is selected, all but the last one on the command line will
  514. be ignored.
  515. X.SH EXAMPLES
  516. To edit one /etc/motd from each class and then update the
  517. others.
  518. X.br
  519. X.DS L
  520. X    foreach\ i\ (`classify\ -1\ /export/root/*/etc/motd`)
  521. X.br
  522. X        set\ ifamily=`classify\ \-m\ $i\ /export/root/*/etc/motd`
  523. X.br
  524. X        vi\ $i
  525. X.br
  526. X        foreach\ j\ ($ifamily)
  527. X.br
  528. X            cp\ $i\ $j
  529. X.br
  530. X        end
  531. X.br
  532. X    end
  533. X.DE
  534. X.SH SEE ALSO
  535. X.BR cmp (1),
  536. X.BR diff (1)
  537. X.SH DIAGNOSTICS
  538. X.TP 5
  539. X.BI "Couldn't open file " filename
  540. Indicates that file
  541. X.I filename
  542. does not exist, or that read priviledges are lacking.
  543. X.TP 5
  544. X.BI "Unknown option: -" option
  545. X.SH AUTHOR
  546. Mark-Jason Dominus, University of Pennsylvania
  547. X.SH BUGS
  548. X.B Classify
  549. should be able to read the standard input as one of the
  550. files.
  551. X.PP
  552. Several performance improvements might be possible.
  553. X.PP
  554. X.B Classify
  555. becomes confused if one of the files it is classifgying is removed
  556. before it is finished.
  557. X.PP
  558. The 
  559. X.B \-l
  560. option is silly since its function can be duplicated with an
  561. X.B awk
  562. script.
  563. X
  564. END_OF_FILE
  565. if test 3519 -ne `wc -c <'classify.1'`; then
  566.     echo shar: \"'classify.1'\" unpacked with wrong size!
  567. fi
  568. # end of 'classify.1'
  569. fi
  570. if test -f 'classify.c' -a "${1}" != "-c" ; then 
  571.   echo shar: Will not clobber existing file \"'classify.c'\"
  572. else
  573. echo shar: Extracting \"'classify.c'\" \(17437 characters\)
  574. sed "s/^X//" >'classify.c' <<'END_OF_FILE'
  575. X
  576. X/*
  577. X * `classify':  Sort files into groups by content
  578. X * Copyright (C) 1991  Mark-Jason Dominus.  All rights reserved.
  579. X *
  580. X * This program is free software; you can redistribute it and/or modify
  581. X * it under the terms of the GNU General Public License as published by
  582. X * the Free Software Foundation; either version 1, or (at your option)
  583. X * any later version.
  584. X *
  585. X * This program is distributed in the hope that it will be useful,
  586. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  587. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  588. X * GNU General Public License for more details.
  589. X * 
  590. X * You should have received a copy of the GNU General Public License
  591. X * along with this program; if not, write to the Free Software
  592. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  593. X */
  594. X
  595. X#include <stdio.h>
  596. X#include <ctype.h>
  597. X#include <string.h>
  598. X
  599. X  /* Return codes from `compare()' and macros for handling them. */
  600. X#define SAME 1
  601. X#define DIFFERENT 0
  602. X#define BADFILE1 4
  603. X#define BADFILE2 8
  604. X#define BADFILEBOTH (BADFILE1 | BADFILE2)
  605. X#define ERROR(RC) ((RC != SAME) && (RC != DIFFERENT))
  606. X
  607. X/* Allocate a new object and return a pointer to it. */
  608. X#define NEW(type) ((type *) malloc(sizeof(type)))
  609. X
  610. X/* Are strings a and b equal?  ('equal', not 'eq') */
  611. X#define STREQ(a,b) (strcmp((a),(b)) == 0)
  612. X
  613. X/* Flags set by command-line options. */
  614. int foldflag = 0, blankflag = 0, whiteflag = 0;
  615. X
  616. X/* Format option and codes. */
  617. char formopt = 's';
  618. X
  619. X/* Explanation of data structure used in this program:
  620. X
  621. X   Each 'masternode'is a linked list of filenames.  The filenames in each
  622. X   masternode are the names of files that are identical, modulo some
  623. X   whitespace and upper/lower-case distinctions.
  624. X
  625. X   The masternodes are linked together in a linked list called `list'.
  626. X
  627. X   Example:
  628. X   
  629. X   list
  630. X   |
  631. X   V          data            next           next 
  632. X   masternode------>filenode------->filenode------>NULL
  633. X   |                  |               |
  634. X   | next             | data          | data
  635. X   |                  V               V
  636. X   |               filename1         filename2
  637. X   |
  638. X   V          data           next 
  639. X   masternode------>filenode------>NULL
  640. X   |                  |
  641. X   | next             | data
  642. X   |                  V
  643. X   V               filename3
  644. X   NULL
  645. X
  646. X   This would represent three files: filename1, filename2, and filename3,
  647. X   of which filename1 and filename2 had the same contents, and filename3
  648. X   was different from both.
  649. X
  650. X   Note:  if j is a pointer to a masternode, then j->data->data is the
  651. X   first filename in j's masternode.
  652. X   */
  653. X   
  654. typedef struct s_fnode {
  655. X  char *data;
  656. X  struct s_fnode *next;
  657. X} filenode;
  658. X
  659. typedef struct s_mnode {
  660. X  filenode *data;
  661. X  struct s_mnode *next;
  662. X} masternode;
  663. X
  664. main(argc,argv)
  665. X     int argc;
  666. X     char *argv[];
  667. X{
  668. X  /* Look at these absurd declarations! */
  669. X  int i, compare(), match, numfileargs, parseargs();
  670. X  void usage(), mappend(), fappend();
  671. X  masternode *list, *j, *mnew, *newmasternode();
  672. X  filenode *fnew, *k, *newfilenode();
  673. X  FILE *checkit;
  674. X  /* Didn't anyone ever tell you it wasn't polite to point? */
  675. X
  676. X  /* Parse the arguments and obliterate switch options like `-f'. */
  677. X  numfileargs = parseargs(argc,argv);
  678. X  /* Anything that survives obliteration is assumed to be a filename. */
  679. X
  680. X  /* No, no--what is the good of comparing only one file? */
  681. X  if (numfileargs < 2) usage(argv[0]);
  682. X
  683. X  /* Find the name of the first file on the command line. */
  684. X  for (i=1; argv[i] == NULL; i++) ;
  685. X
  686. X  /* This program has two essentially separate functions.
  687. X   * One is to take a list of files and group identical ones.
  688. X   * The other is to see which of files 2...n are identical to
  689. X   * file 1.
  690. X   *
  691. X   * If you specify -m or -M, you get the second
  692. X   * functionality. Otherwise, you get the first.
  693. X   *
  694. X   * What follows right here is the second functionality.
  695. X   */
  696. X
  697. X  if (formopt == 'm' || formopt == 'M') {
  698. X
  699. X    /* The first file the user named is the one to check the others against.
  700. X     */
  701. X    char *master = argv[i];    
  702. X    
  703. X    /* If the user said '-M', echo the name of the master 
  704. X     * file; if not, suppress it. */
  705. X    if (formopt == 'M')
  706. X      printf("%s\n",master);
  707. X    
  708. X    for (i += 1; i<argc; i++) {
  709. X      if (argv[i] == NULL) continue;
  710. X
  711. X      /* If for some reason the name of the master file appears more than
  712. X     once on the command line, suppress it. (This happens all the time
  713. X     in shell scripts.)
  714. X     */
  715. X      if (STREQ(argv[i], master)) continue;
  716. X              
  717. X      match = compare(master, argv[i]);
  718. X      if (match == SAME)
  719. X    printf("%s\n", argv[i]);
  720. X      /* If `match' was an error return, `compare()' printed an error */
  721. X      /* message for us and we need do nothing special. */
  722. X    }
  723. X
  724. X    exit(0); /* This part of the program can't fail. */
  725. X  }
  726. X
  727. X  /* If we're here, then the user didn't select -m or -M, and we
  728. X     do the normal thing, which is to look at all the files and sort them
  729. X     into groups.
  730. X     */
  731. X
  732. X  /* This next bit of code catches a peculiar bug: If it were not here, and
  733. X     if we couldn't open the first file named on the command line, we would
  734. X     put it into the linked list anyway (list->data->data = argv[i]) and
  735. X     subsequent files would get checked against it, yielding many error
  736. X     messages, much wasted time, and erroneous output--there would be a
  737. X     `Class 1' with the bad file alone in it.
  738. X
  739. X     Putting in this check allows us to make much simpler
  740. X     list-initialization code.  I hate writing special-case code for
  741. X     starting off linked lists!
  742. X     */
  743. X  while (((checkit = fopen(argv[i],"r")) == NULL) &&
  744. X     i < argc)
  745. X    fprintf(stderr, "Couldn't open file %s.\n", argv[i++]);
  746. X  fclose(checkit);
  747. X
  748. X  if (i == argc) exit(0); /* Couldn't read *any* of the input files. */
  749. X
  750. X  /* Initialize linked lists */
  751. X  list = newmasternode();
  752. X  list->data->data = argv[i];
  753. X  /* Wasn't that simple?  Told you so. */
  754. X  
  755. X  for (i += 1; i < argc; i++) { /* Loop through filenames... */
  756. X    if (argv[i] == NULL) continue; /* ... skipping nulls ... */
  757. X    match = DIFFERENT;
  758. X    j=list; 
  759. X    do {
  760. X      /* ... matching the current file with the file at the head of each */
  761. X      /* class-list ... */
  762. X      match = compare(argv[i], j->data->data); 
  763. X      if (match == DIFFERENT) j = j->next; 
  764. X      /* ... until we run out of class lists or find a match or an error. */
  765. X    } while (j && (match == DIFFERENT)); 
  766. X
  767. X    /* Now, if there was an error, then... */
  768. X    if (ERROR(match)) {
  769. X      /* ... I hope it was in the current file--that's no problem; we just
  770. X     obliterate it from the list of files to check, and move on, but...
  771. X     */
  772. X      if ((match & BADFILE1) == BADFILE1) {
  773. X    argv[i] = NULL;
  774. X    continue;
  775. X      }
  776. X      /* ... if the problem was with the file in the class list, I am very
  777. X     upset, because it _was_ okay when I put it into the list.
  778. X     (I have violated Steinbach's Guideline for Systems Programming:
  779. X     ``Never test for an error condition you don't know how to
  780. X     handle.''  But actually I could handle this; we could delete the
  781. X     bogus file from the class-list in which it appears.  This is a lot
  782. X     of work and it will happen only very rarely and in bizarre
  783. X     circumstances, so I choose not to bother.  So sue me.
  784. X     */
  785. X      else if ((match & BADFILE2) == BADFILE2) {
  786. X    fprintf(stderr,"WARNING:\tSomething went wrong with file %s\n",
  787. X        j->data->data);
  788. X    fprintf(stderr,"since the last time I looked at it.\n");
  789. X    /* Yes, Virginia, this is correct behavior. */
  790. X      }
  791. X    }
  792. X
  793. X    /* Okay, there was no error, but the current file was *not* like
  794. X       any of the ones we've seen so far.  Make a new classification and
  795. X       put the current filename into it.
  796. X       */
  797. X    else if (match == DIFFERENT) {
  798. X      mnew = newmasternode();
  799. X      mnew->data->data = argv[i];
  800. X      mappend(list,mnew);
  801. X    }
  802. X    /* Ah, we found a match--the current file is identical to the ones in */
  803. X    /* the classification j->data. */
  804. X    else {
  805. X#ifdef DEBUG
  806. X      fprintf(stderr, "%s matched %s.\n", argv[i], j->data->data);
  807. X#endif
  808. X      fnew = newfilenode();
  809. X      fnew->data = argv[i];
  810. X      fappend(j->data, fnew);
  811. X    }
  812. X  } /* for (i += 1; ... ) */
  813. X
  814. X  /* We are out of the main loop and all the files have been handled,
  815. X     one way or another.  Now it is time to spit out the output.
  816. X     */
  817. X
  818. X  /* `formopt' is '1' if the user selected the `-1' option.  It means 
  819. X   * that the proram should not do the default thing, which is to make a 
  820. X   * nice long report of who matched whom, but rather should just dump out 
  821. X   * a list of files each of which represents exactly one of the classes. */
  822. X  if (formopt == '1') {
  823. X    for (j=list; j; j=j->next)
  824. X      printf("%s\n", j->data->data);
  825. X  }
  826. X  /* `formopt' is 's' if the user selected the '-s' option.  That 
  827. X   * means that the program should make a short, awkable kind of
  828. X   * output, with one line per class, filenames separated by a single
  829. X   * space.  Note that we do not number the lines.  (I almost had it
  830. X   * number the lines.)  The idea is that if the user wanted the lines
  831. X   * numbered, they would pipe the output through 'cat -n'. */
  832. X  else if (formopt == 's') {
  833. X    for (j=list; j; j=j->next) {
  834. X      for (k = j->data; k; k=k->next) 
  835. X    printf("%s ", k->data);
  836. X      printf("\n");
  837. X    }
  838. X  }
  839. X  /* Here we make the nice long report. The temptation to add many
  840. X     bells and whistles and have the program accept a format-specification
  841. X     string and so on is very tempting, but I will not give in to foolish
  842. X     creeping featurism.  At least, not any more than I already have.
  843. X     Actually, a short-form option, the puts the output in the form
  844. X             1 foo.c bar.c baz.c la.c
  845. X         2 la de da oakum yokum
  846. X         3 cruft FOCUS
  847. X         4 adventure
  848. X     might be very useful, because as it is you can't really feed this
  849. X     program's output to AWK in a reasonable way.
  850. X     */
  851. X  /* Note added in proof:  I gave in to creeping featurism.  See the 
  852. X   * '-s' option.  Sigh.  At least I did not make it number the lines. */
  853. X  else {
  854. X    for (j=list, i=1; j; j=j->next, i++) {
  855. X      printf("\nClass %d:\n",i);
  856. X      for (k = j->data; k; k=k->next) {
  857. X    printf("\t%s\n",k->data);
  858. X      }
  859. X    }
  860. X  }
  861. X   
  862. X  exit(0); /* Au 'voir! */
  863. X}
  864. X
  865. X/* This next `compare' routine is what I used to do, but there are good
  866. X   reasons for not using either diff(1) or cmp(1): 
  867. X
  868. X   1.  Do not use diff(1) because it is too intelligent (intelligent ->
  869. X   slow.)  Diff tells you where the files differ and that is not what we
  870. X   want--we just want to know if they are different or not.
  871. X
  872. X   2.  Do not use cmp(1) because we want to use this program for comparing
  873. X   things like /etc/rc.local and /etc/motd which are very likely to differ
  874. X   only in a few whitespaces, and we want this program to report that such
  875. X   files are identical, even though cmp says they're not.
  876. X
  877. X   Maybe UNIX needs a nice, simple, flexible file-compare utility?  Naah,
  878. X   you can always string awk and sed and things onto the front of cmp.  But
  879. X   that's too slow for us here.
  880. X   */
  881. X
  882. X/* Do not do this:
  883. X  int  
  884. X  compare(path1,path2)
  885. char *path1, *path2;
  886. X{
  887. X  char compare[1024];
  888. X
  889. X  sprintf(compare,"cmp -s %s %s",path1,path2); 
  890. X  sprintf(compare,"diff -w %s %s > /dev/null 2>&1",path1,path2); 
  891. X  return((system(compare) >> 8 == 0) ? SAME : DIFFERENT );
  892. X}
  893. X*/
  894. X
  895. X/* So this is what we do instead. */
  896. X
  897. int
  898. X  compare(path1, path2)
  899. char *path1, *path2;
  900. X{
  901. X  FILE *file1, *file2;
  902. X  int c1,c2;
  903. X
  904. X  if ((file1 = fopen(path1,"r")) == NULL) {
  905. X    fprintf(stderr, "Couldn't open file %s.\n", path1);
  906. X    return(BADFILE1);
  907. X  }
  908. X  if ((file2 = fopen(path2,"r")) == NULL) {
  909. X    fprintf(stderr, "Couldn't open file %s.\n", path2);
  910. X    return(BADFILE2); /* For symmetry, even though this program will become
  911. X             quite irate if `compare' ever returns this code.
  912. X             */
  913. X  }
  914. X
  915. X  do {
  916. X    do {
  917. X      c1 = getc(file1);
  918. X      /* You may need to make a Karnaugh map to understand this termination
  919. X     condition, but it essentially means to ignore the right white spaces
  920. X     if the right option flags are set, and I have tested it for you,
  921. X     so you may assume it is doing the thing that the man page says it
  922. X     does.
  923. X     */
  924. X    } while (! ((!blankflag && !whiteflag) ||
  925. X        ((c1 != ' ' && c1 != '\t') && (c1 != '\n'  || !whiteflag)))
  926. X         ) ;
  927. X    do {
  928. X      c2 = getc(file2);
  929. X    } while (! ((!blankflag && !whiteflag) || /* Ditto */
  930. X        ((c2 != ' ' && c2 != '\t') && (c2 != '\n'  || !whiteflag)))
  931. X         ) ;
  932. X
  933. X    /* Fold case if requested with `-f' flag. */
  934. X    if (foldflag) {
  935. X      c1 = (isupper(c1) ? tolower(c1) : c1);
  936. X      c2 = (isupper(c2) ? tolower(c2) : c2);
  937. X    }
  938. X    
  939. X    if (c1 != c2) {
  940. X      fclose(file1);
  941. X      fclose(file2);
  942. X      return DIFFERENT;
  943. X    }
  944. X
  945. X  } while (c1 != EOF && c2 != EOF);
  946. X
  947. X  fclose(file1);
  948. X  fclose(file2);
  949. X
  950. X  /* If we're here, then both files were identical and we tapped out at */
  951. X  /* least one of them.  If we tapped out both, they really are identical. */
  952. X  /* If, on the other hand, only one is finished, then it is a strict */
  953. X  /* prefix of the other and so the two files are *not* the same. */
  954. X  if (c1 == EOF && c2 == EOF)
  955. X    return SAME;
  956. X  else
  957. X    return DIFFERENT;
  958. X}
  959. X
  960. X/* Nyahh nyah!  User is a big stupid-head! */
  961. void
  962. X  usage(progname)
  963. char *progname;
  964. X{
  965. X  char *tail;
  966. X  tail = strrchr(progname,'/');
  967. X
  968. X  if (tail) progname = tail+1;
  969. X  fprintf(stderr,"Usage:\t %s [-1 | -s | -l | -m | -M] [-f] [-b | -w]\n",progname);
  970. X  fprintf(stderr,"\tfile1 file2 [...]\n");
  971. X  fprintf(stderr,"\n\nTry %s -h\t for help.\n", progname);
  972. X  exit(-1);
  973. X}
  974. X
  975. X/* I put this here 'cause I didn't want to write a man page. Duuhhhhh. */
  976. void
  977. X  help()
  978. X{
  979. X  fprintf(stderr,"Classify: Examine and group identical files.\n\n");
  980. X  fprintf(stderr,"Flags:\n\t-f\tFold case in file comparisions.\n");
  981. X  fprintf(stderr,"\t-b\tIgnore blanks and TABs in file comparisions.\n");
  982. X  fprintf(stderr,"\t-w\tIgnore all whitespace in file comparisions.\n");
  983. X  fprintf(stderr,"\t-1\tPrint the name of only one file from each class.\n");
  984. X  fprintf(stderr,"\t-l\tPrint  long-format output (default).\n");
  985. X  fprintf(stderr,"\t-s\tPrint short-format output.\n");
  986. X  fprintf(stderr,"\t-M\tPrint only names of files that match first file named.\n");
  987. X  fprintf(stderr,"\t-m\tLike -M, but suppress first filename.\n");
  988. X  return;
  989. X}
  990. X
  991. X/* Parse the args and set the flags.
  992. X   We want the argument list to be free-form so you can mix filenames and
  993. X   options. That is because I am a masochist.  So to save trouble, we just
  994. X   obliterate the flag arguments by setting them to NULL, and then we have
  995. X   the main routine ignore NULL arguments if it sees any.  Programmers who
  996. X   say `but then you can't tell when you've reached the end of the arg list
  997. X   because it is supposed to be a NULL-terminated array!' get a boot to the
  998. X   head. 
  999. X
  1000. X   Returns the number of non-flag arguments.
  1001. X   */
  1002. X   
  1003. int
  1004. X  parseargs(argc,argv)
  1005. int argc;
  1006. char *argv[];
  1007. X{
  1008. X  int i, j, numnonflags = argc-1;
  1009. X  void usage(), help();
  1010. X
  1011. X  for (i=1; i<argc; i++) {
  1012. X    if (argv[i][0] != '-') continue;
  1013. X    numnonflags -= 1;
  1014. X    if (argv[i][1] == '\0') {  /* If flag is "-", stop parsing args */
  1015. X      /* Probably `-' should mean to read the stdin.  I will put in
  1016. X     that feature three days after next tishabov.
  1017. X
  1018. X     (Translation for gentiles:  I will put the feature in on the
  1019. X     fourth Thursday of next week. )
  1020. X     */
  1021. X      argv[i] = NULL;
  1022. X      return numnonflags;
  1023. X    }
  1024. X    for (j=1; argv[i][j]; j++) {
  1025. X      switch (argv[i][j]) {
  1026. X      case '-': /* If flag is "--", stop parsing args */
  1027. X    if (j==1) {
  1028. X      argv[i] = NULL;
  1029. X      return;
  1030. X    } /* Else we got a flag like -f-w, so ignore the second "-" sign. */
  1031. X    break;
  1032. X      case 'f':
  1033. X    foldflag = 1;
  1034. X    break;
  1035. X      case 'b':
  1036. X    blankflag = 1;
  1037. X    break;
  1038. X      case 'w':
  1039. X    whiteflag = 1;
  1040. X    break;
  1041. X      case 'l':
  1042. X    formopt = 'l';
  1043. X    break;
  1044. X      case 's':
  1045. X    formopt = 's';
  1046. X    break;
  1047. X      case '1':
  1048. X    formopt = '1';
  1049. X    break;
  1050. X      case 'h':
  1051. X    help(); /* ``Why does this function return?''
  1052. X           `` `Cause you're an idiot.''
  1053. X           ``Oh yeah.  I forgot.''
  1054. X           */
  1055. X    exit(0);
  1056. X    break;
  1057. X      case 'm':
  1058. X    formopt = 'm';
  1059. X    break;
  1060. X      case 'M':
  1061. X    formopt = 'M';
  1062. X    break;
  1063. X      default:
  1064. X    fprintf(stderr, "Unknown option: -%c.\n", argv[i][j]);
  1065. X    usage(argv[0]);
  1066. X      }
  1067. X    }
  1068. X    if (argv[i][0] == '-') argv[i] = NULL; /* Obliterate flag arguments. */
  1069. X  }
  1070. X  return numnonflags;
  1071. X}
  1072. X
  1073. X/* Manufacture a new masternode whose car is a new filenode.  Return a */
  1074. X/* pointer to the new masternode. */
  1075. masternode *
  1076. X  newmasternode()
  1077. X{
  1078. X  masternode *foo;
  1079. X  filenode *newfilenode();
  1080. X
  1081. X  foo = NEW(masternode);
  1082. X  foo->next = NULL;
  1083. X  foo->data = newfilenode();
  1084. X
  1085. X  return(foo);
  1086. X}
  1087. X
  1088. X/* Manufacture a new filenode whose car is the null string.  Return a */
  1089. X/* pointer to the new filenode. */
  1090. filenode *
  1091. X  newfilenode()
  1092. X{
  1093. X  filenode *foo;
  1094. X  
  1095. X  foo = NEW(filenode);
  1096. X  foo->next = NULL;
  1097. X  foo->data = NULL;
  1098. X  
  1099. X  return(foo);
  1100. X}
  1101. X
  1102. X/* head and tail are pointers to masternodes.  (i.e., they are linked lists */
  1103. X/* of masternodes.)  Append tail to the end of head.  (LISP pepole would */
  1104. X/* call this operation `nconc'.  I can't say the word `nconc' without */
  1105. X/* bursting out laughing, so I called it `mappend' instead.) */
  1106. void
  1107. X  mappend(head,tail)
  1108. masternode *head, *tail;
  1109. X{
  1110. X  masternode *i;
  1111. X
  1112. X  /* Find the end of the linked list `head' */
  1113. X  for (i=head; i->next; i = i->next) ;
  1114. X
  1115. X  /* Concatenate. */
  1116. X  i->next = tail;
  1117. X
  1118. X  return;
  1119. X}
  1120. X  
  1121. X/* This is the same as mappend, except it works on filenode-lists instead */
  1122. X/* of masternode-lists.  Big deal.  */
  1123. void
  1124. X  fappend(head,tail)
  1125. filenode *head, *tail;
  1126. X{
  1127. X  filenode *i;
  1128. X  
  1129. X  for (i=head; i->next; i = i->next) ;
  1130. X
  1131. X  /* nconc!  nconc!  nconc!  hahahaha! */
  1132. X  i->next = tail;
  1133. X
  1134. X  return;
  1135. X}
  1136. X    
  1137. X
  1138. END_OF_FILE
  1139. if test 17437 -ne `wc -c <'classify.c'`; then
  1140.     echo shar: \"'classify.c'\" unpacked with wrong size!
  1141. fi
  1142. # end of 'classify.c'
  1143. fi
  1144. if test -f 'test0' -a "${1}" != "-c" ; then 
  1145.   echo shar: Will not clobber existing file \"'test0'\"
  1146. else
  1147. echo shar: Extracting \"'test0'\" \(28 characters\)
  1148. sed "s/^X//" >'test0' <<'END_OF_FILE'
  1149. this is the forest primeval
  1150. END_OF_FILE
  1151. if test 28 -ne `wc -c <'test0'`; then
  1152.     echo shar: \"'test0'\" unpacked with wrong size!
  1153. fi
  1154. # end of 'test0'
  1155. fi
  1156. if test -f 'test1' -a "${1}" != "-c" ; then 
  1157.   echo shar: Will not clobber existing file \"'test1'\"
  1158. else
  1159. echo shar: Extracting \"'test1'\" \(28 characters\)
  1160. sed "s/^X//" >'test1' <<'END_OF_FILE'
  1161. this is the forest primeval
  1162. END_OF_FILE
  1163. if test 28 -ne `wc -c <'test1'`; then
  1164.     echo shar: \"'test1'\" unpacked with wrong size!
  1165. fi
  1166. # end of 'test1'
  1167. fi
  1168. if test -f 'test2' -a "${1}" != "-c" ; then 
  1169.   echo shar: Will not clobber existing file \"'test2'\"
  1170. else
  1171. echo shar: Extracting \"'test2'\" \(31 characters\)
  1172. sed "s/^X//" >'test2' <<'END_OF_FILE'
  1173. this is     the        forest  primeval
  1174. END_OF_FILE
  1175. if test 31 -ne `wc -c <'test2'`; then
  1176.     echo shar: \"'test2'\" unpacked with wrong size!
  1177. fi
  1178. # end of 'test2'
  1179. fi
  1180. if test -f 'test3' -a "${1}" != "-c" ; then 
  1181.   echo shar: Will not clobber existing file \"'test3'\"
  1182. else
  1183. echo shar: Extracting \"'test3'\" \(36 characters\)
  1184. sed "s/^X//" >'test3' <<'END_OF_FILE'
  1185. X
  1186. this is the forest         primeval
  1187. X
  1188. X
  1189. END_OF_FILE
  1190. if test 36 -ne `wc -c <'test3'`; then
  1191.     echo shar: \"'test3'\" unpacked with wrong size!
  1192. fi
  1193. # end of 'test3'
  1194. fi
  1195. if test -f 'test4' -a "${1}" != "-c" ; then 
  1196.   echo shar: Will not clobber existing file \"'test4'\"
  1197. else
  1198. echo shar: Extracting \"'test4'\" \(28 characters\)
  1199. sed "s/^X//" >'test4' <<'END_OF_FILE'
  1200. THIS is the forest primeval
  1201. END_OF_FILE
  1202. if test 28 -ne `wc -c <'test4'`; then
  1203.     echo shar: \"'test4'\" unpacked with wrong size!
  1204. fi
  1205. # end of 'test4'
  1206. fi
  1207. echo shar: End of shell archive.
  1208. exit 0
  1209.